import {request} from "vendor/utils/T";
import {toApi} from "@/service/proxyApi";
import {RequestDataType, RespDataType} from "./apiType";

export * from "./apiType";


const {get, postJSON, del, put, upload} = request;

export { getOrgDetail } from '@/components/app/commonSystemSetting/api';

/**
 * 创建组织
 */
export const createOrganization = (params: RequestDataType.addOrganizationItem) => {
    return postJSON(toApi("system/dept"), params);
}

/**
 * 删除组织
 */
export const delOrganization = (deptId: number) => {
    return del(toApi("system/dept/" + deptId));
}

/**
 * 获取组织列表数据
 */
export const getOrgDataList = (params:RequestDataType.queryOrganizationItem) => {
    return get<RespDataType.DeptItemInfo[]>(toApi("system/dept/listTree"),params);
}

/**
 * 更新组织信息
 */
export const updateOrgData = (params: Partial<RequestDataType.UpdateOrganizationItem>) => {
    return put(toApi("system/dept"),params);
}

// /**
//  * 更新组织额外信息
//  */
// export const updateOrgExtraInfo = (params: {deptId: string, extraInfo: string}) => {
//     return put(toApi("system/dept/extraInfo"),params);
// }

/**
 * 获取下载二维码的地址
 */
export const getDownloadQRCodeUrl = (deptId: string) => get<string>(toApi(`qrcode/create?deptId=${deptId}`));

// /**
//  * 获取组织树数据
//  */
// export const getOrgTreeData = () => get<RespDataType.TreeSelectData[]>(toApi("system/dept/treeSelectData"));

// /**
//  * 保存实体详情
//  */
// export const saveEntityDetail = (entityId:string, params: any) => put(toApi(`entity?entityId=${entityId}`), params);
//
// /**
//  * 上传实体中的图片
//  */
// export const uploadEntityImage = (params: {imgfile: File}) => upload<{imgUrl: string}>(toApi("entity/image"), params);



